# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=scratchabit
pkgver=565.d93d759
pkgrel=6
pkgdesc='Easily retargetable and hackable interactive disassembler with IDAPython-compatible plugin API.'
groups=('blackarch' 'blackarch-disassembler')
arch=('any')
url='https://github.com/pfalcon/ScratchABit'
license=('custom:unknown')
depends=('python3')
makedepends=('git')
_gitroot='https://github.com/pfalcon/ScratchABit.git'

pkgver() {
  cd ScratchABit

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  git clone --recursive $_gitroot
}

package() {
  cd ScratchABit

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md docs/*

  rm -rf README.md docs

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python3 ScratchABit.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

